package Interface.Admin;

import Mapper.Admin.huoDongFaBuMapper;
import Mapper.Admin.zhujiemian;
import javafx.application.Application;
import javafx.scene.control.Alert;
import javafx.scene.control.TextInputDialog;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.stage.Stage;

import java.io.FileInputStream;

public class huoDongFaBu extends Application {
    private static String name;
    private static String huodong;
    huoDongFaBuMapper huoDongFaBuMapper;
    @Override
    public void start(Stage stage) throws Exception {
        FileInputStream input=new FileInputStream("C:\\Users\\86178\\Videos\\Captures\\走路.gif");
        Image image = new Image(input);
        ImageView imageView =new ImageView(image);
        imageView.setFitWidth(488);
        imageView.setFitHeight(465);
        huoDongFaBuMapper=new huoDongFaBuMapper();

        // 创建一个输入对话框
        TextInputDialog dialog = new TextInputDialog();
        dialog.setTitle("发布活动");
        dialog.setHeaderText(null);
        dialog.setContentText("请输入活动名称:");

        // 显示对话框并等待用户输入
        dialog.showAndWait().ifPresent(courseName -> {
            // 用户点击确定后，获取课程名称
            if (!courseName.isEmpty()) {
                //Add_course(courseName);
                name=courseName;
            } else {
                // 输入为空，弹出提示框
                Alert alert = new Alert(Alert.AlertType.ERROR);
                alert.setTitle("错误");
                alert.setHeaderText(null);
                alert.setContentText("课程名称不能为空！");
                alert.showAndWait();
            }
        });

        // 创建一个输入对话框
        TextInputDialog dialog2 = new TextInputDialog();
        dialog2.setTitle("活动内容");
        dialog2.setHeaderText(null);
        dialog2.setContentText("请输入活动内容:");

        // 显示对话框并等待用户输入
        dialog2.showAndWait().ifPresent(courseName -> {
            // 用户点击确定后，获取课程名称
            if (!courseName.isEmpty()) {
                //Add_course(courseName);
                huodong=courseName;
                Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
                alert.setTitle("成功");
                alert.setHeaderText(null);
                alert.setContentText("发布成功！");
                alert.showAndWait();
            } else {
                // 输入为空，弹出提示框
                Alert alert = new Alert(Alert.AlertType.ERROR);
                alert.setTitle("错误");
                alert.setHeaderText(null);
                alert.setContentText("课程名称不能为空！");
                alert.showAndWait();
            }
        });
        huoDongFaBuMapper.insert(name,huodong);
    }
}
